Skip to content

Implement synchronized shifting for child elements#47

Merged
patrickersing merged 18 commits intopatrickersing:amr_limiterfrom
bennibolm:amr_limiter_synchronized
Aug 29, 2025
Merged

Implement synchronized shifting for child elements#47
patrickersing merged 18 commits intopatrickersing:amr_limiterfrom
bennibolm:amr_limiter_synchronized

Conversation

@bennibolm
Copy link
Copy Markdown
Collaborator

@bennibolm bennibolm commented Jul 28, 2025

In this PR, I implemented a first version where freshly refined elements are shifted simultaneously (with the same theta) towards the mean value of their parent element (if necessary).
For now, I haven't found an example where the implementation without simultaneous shifting preserves conservation and the one without doesn't. I'll test some more setups.
see trixi-framework#2396

@github-actions
Copy link
Copy Markdown

Review checklist

This checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging.

Purpose and scope

  • The PR has a single goal that is clear from the PR title and/or description.
  • All code changes represent a single set of modifications that logically belong together.
  • No more than 500 lines of code are changed or there is no obvious way to split the PR into multiple PRs.

Code quality

  • The code can be understood easily.
  • Newly introduced names for variables etc. are self-descriptive and consistent with existing naming conventions.
  • There are no redundancies that can be removed by simple modularization/refactoring.
  • There are no leftover debug statements or commented code sections.
  • The code adheres to our conventions and style guide, and to the Julia guidelines.

Documentation

  • New functions and types are documented with a docstring or top-level comment.
  • Relevant publications are referenced in docstrings (see example for formatting).
  • Inline comments are used to document longer or unusual code sections.
  • Comments describe intent ("why?") and not just functionality ("what?").
  • If the PR introduces a significant change or new feature, it is documented in NEWS.md with its PR number.

Testing

  • The PR passes all tests.
  • New or modified lines of code are covered by tests.
  • New or modified tests run in less then 10 seconds.

Performance

  • There are no type instabilities or memory allocations in performance-critical parts.
  • If the PR intent is to improve performance, before/after time measurements are posted in the PR.

Verification

  • The correctness of the code was verified using appropriate tests.
  • If new equations/methods are added, a convergence test has been run and the results
    are posted in the PR.

Created with ❤️ by the Trixi.jl community.

Comment thread src/callbacks_stage/positivity_zhang_shu_dg2d.jl Outdated
@bennibolm bennibolm marked this pull request as ready for review August 19, 2025 13:20
@bennibolm
Copy link
Copy Markdown
Collaborator Author

bennibolm commented Aug 19, 2025

All tests are working. They are only shown as failing because the codecov upload fails since it's a branch on my fork.

@bennibolm
Copy link
Copy Markdown
Collaborator Author

My first implementation is ready. Now, I first compute the (nonnegative) mean solution of elements that are going to be refined before the refinement process and then pass that information to the limiter. Then, all the 4 child elements are shifted w.r.t. this mean and with the same theta.
I'm already using this implementation in a branch of mine where I use mortars with subcell limiting. There it works very good.
Unfortunately, I'm struggling with finding a good example without subcell limiting. What were elixirs and setups where you found positivity issues with the solution transfer during the refinement/coarsening process?

Copy link
Copy Markdown
Owner

@patrickersing patrickersing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bennibolm Thanks a lot for moving this forward!

Comment thread src/callbacks_stage/positivity_zhang_shu.jl Outdated
Comment thread src/callbacks_stage/positivity_zhang_shu_dg1d.jl Outdated
Comment thread src/callbacks_stage/positivity_zhang_shu_dg1d.jl Outdated
Comment thread src/callbacks_stage/positivity_zhang_shu_dg1d.jl Outdated
Comment thread src/callbacks_stage/positivity_zhang_shu_dg1d.jl Outdated
Comment thread src/callbacks_stage/positivity_zhang_shu_dg2d.jl Outdated
Comment thread src/callbacks_stage/positivity_zhang_shu_dg3d.jl Outdated
Comment thread src/callbacks_stage/positivity_zhang_shu_dg2d.jl Outdated
Comment thread src/callbacks_stage/positivity_zhang_shu_dg1d.jl Outdated
Comment thread src/callbacks_stage/positivity_zhang_shu_dg3d.jl Outdated
@patrickersing
Copy link
Copy Markdown
Owner

Unfortunately, I'm struggling with finding a good example without subcell limiting. What were elixirs and setups where you found positivity issues with the solution transfer during the refinement/coarsening process?

I remember that there were positivity issues in the elixir p4est_2d_dgsem/elixir_euler_double_mach_amr.jl. The simulation didn't crash, but you should see negative value if you check just before the limiter call in the refinement routine.

@bennibolm
Copy link
Copy Markdown
Collaborator Author

Thanks for all the comments. I will apply the suggestions and/or answer in the next few days.

I remember that there were positivity issues in the elixir p4est_2d_dgsem/elixir_euler_double_mach_amr.jl. The simulation didn't crash, but you should see negative value if you check just before the limiter call in the refinement routine.

Okay, thanks. I will try this.

Comment thread src/callbacks_stage/positivity_zhang_shu_dg1d.jl Outdated
@bennibolm
Copy link
Copy Markdown
Collaborator Author

I tested the p4est_2d_dgsem/elixir_euler_double_mach_amr.jl for the positivity issues. As I found out before and also wrote somewhere, the issue appears during the initialization process of the amr callback - i.e. when the initial refinement level is lower than some amr level, and we need refinement at the start.
In this specific example, we get some negative values for pressure after refinement. Applying the limiter fixes this issue - in both cases: with joint limiting for refined elements and without.

Comment thread src/callbacks_stage/positivity_zhang_shu.jl Outdated
Comment thread src/callbacks_stage/positivity_zhang_shu_dg2d.jl Outdated
Comment thread src/callbacks_stage/positivity_zhang_shu_dg1d.jl Outdated
Comment thread src/callbacks_stage/positivity_zhang_shu_dg1d.jl Outdated
Comment thread src/callbacks_step/amr.jl
Copy link
Copy Markdown
Owner

@patrickersing patrickersing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Nice that you also managed to apply this strategy for the coarsening step.

@patrickersing patrickersing merged commit 544ac69 into patrickersing:amr_limiter Aug 29, 2025
8 of 35 checks passed
@bennibolm bennibolm deleted the amr_limiter_synchronized branch August 29, 2025 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants